package com.example.demossssssssss.Controller;

import com.example.demossssssssss.Entity.News;
import com.example.demossssssssss.Service.NewsService;
import com.example.demossssssssss.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@Api(value = "News", description = "新闻")
@RequestMapping(value = "/news")
//ioexception 爆出程序异常
public class NewsContriller {

    @Autowired
    private NewsService newsService;

    @ApiOperation(value = "添加新闻", notes = "添加新闻")
    @RequestMapping(value = "/News/addNews", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    //接口url，请求方式，数据格式
    public Object addNewsbb(@RequestBody News news) throws IOException {
        newsService.addNews(news);
        return "成功";
    }
}
